﻿<?php
    include('php/includes/definer.php');
    include('admin/php/clases/Texto.php');
    include('admin/php/bootstrap.php');
    include('php/twitter/tweets.php');
    $tweets = get_latest_tweets();
    $ABOUT_ME = Doctrine::getTable('publicacion')->findOneById(6);
?>
<!DOCTYPE html>
<head>
    <title>LuCelasco.com</title>
    <meta name="description" content="" />
    <meta name="google-site-verification" content="m3Rzxsp37nB8vvBYegZW5urJr5dn0TgMDaMJ3ZkP6g4" />

    <!-- Facebook -->
    <meta property="og:title" content="LuCelasco.com" />
    <meta property="og:site_name" content="Lucía Celasco"/>
    <meta property="og:type" content="blog"/>
    <meta property="og:image" content="<?php echo(URL); ?>img/lucelasco-facbook-og.jpg" />
    <meta property="og:url" content="<?php echo(URL); ?>" />
    <meta property="og:description" content="Lucelasco.com es mi espacio para compartir experiencias, mi gusto por el diseño, mi pasión por los viajes y mi nueva incursión en la fotografía." />

    <!-- Twitter -->          
    <meta name="twitter:card" content="summary" />
    <meta name="twitter:title" content="LuCelasco.com" />
    <meta name="twitter:description" content="Lucelasco.com es mi espacio para compartir experiencias, mi gusto por el diseño, mi pasión por los viajes y mi nueva incursión en la fotografía." />
    <?php include('common/head.php') ?>
</head>
<body>
<main>
    <?php include('common/header.php') ?>
    <div class="main-content home">
        <div class="wrapper">
            <div class="slider">
                <div class="loader">
                    <img src="img/loader.gif" alt="" />
                </div>
                <div id="slides">
                    <?php include('php/printers/slider.printer.php'); ?>
                </div>
            </div>

            <aside class="main-aside">
                <div class="about">
                    <h4>
                        <i class="fa fa-star"></i><span>About me</span>
                    </h4>
                    <a href="about-me">
                        <img src="content/images/thumb/<?php echo($ABOUT_ME->thumb); ?>" alt="Lucía Celasco" title="Lucía Celasco" />
                    </a>
                    <p>
                        <?php echo(Texto::cortar(strip_tags($ABOUT_ME->contenido), 144, '...')); ?>
                    </p>
                    <a href="about-me">Más sobre Lucía</a>
                </div>
                
                <div class="last-tweet">
                    <h4>
                        <i class="fa fa-twitter"></i><span>Último tweet</span>
                    </h4>
                    <p>“<span id="last-tweet"><?php echo($tweets[0]->text) ?></span>”</p>
                </div>
                
                <div class="instagram-feed">
                    <h4><i class="fa fa-instagram"></i><span>Instagram</span></h4>
                    <div class="thumbs-grid"></div> <!-- CONTENT GENERATED -->
                </div>
                
                <div class="adv-aside">
                    <div class="content"></div>
                </div>
            </aside>

            <div class="posts">
                <div class="loader">
                    <img src="img/loader.gif" alt="" />
                </div>
                <div id="masonry">
                    <div class="posts-border"></div>
                    <div class="grid-sizer"></div>
                    <?php
                        $cuantos = 10;
                        $size = 'half';
                        include('php/printers/postList.printer.php');
                    ?>
                </div>
            </div>
        </div>
        <nav class="posts-navigation">
            <div class="wrapper">
                <div class="posts-pagination">
                    <?php echo(Paginador::printNumbers($cuantos, $total, $pagina)); ?>
                </div>
                <?php include('php/printers/selectMes.printer.php'); ?>
            </div>
        </nav>
    </div>
    <?php include('common/footer.php') ?>
</main>

<?php include('common/scripts.php') ?>
<script type="text/javascript" src="js/jquery.slides.min.js"></script>
<script type="text/javascript" src="js/masonry.min.js"></script>
<script type="text/javascript" src="js/instagram.min.js" async></script>
<script type="text/javascript" src="js/plugin/jquery-timeago/jquery-timeago.min.js"></script>
<script type="text/javascript" src="js/plugin/jquery-timeago/jquery-timeago-es.min.js"></script>
<script type="text/javascript" src="js/lurocks.min.js"></script>
<script>
    var CATEGORIA = 'home';
    $('.select').removeClass('no-js');
    $(document).on('change', 'select', function() {
        var selected = $('option:selected', this).text();
        $(this).siblings('.current').text(selected);
        window.location = $(this).val().replace(/([a-z]+) ([0-9]{4})/, '$2/$1');
    });
    
   function reloadPublicidad () {
        $('.adv-aside .content').html('');
        var banner;
        publicidad.getMediums(CATEGORIA, false, function () {
            while (banner = publicidad.showMedium()) {
                if (!$('.adv-aside h4').length) $('.adv-aside').prepend('<h4>Publicidad</h4>');
                $('.adv-aside .content').append(banner);
            }
        });
    }

    var $mason_img = $('#masonry').find('img');
    if ($mason_img.length != 0) {
        $mason_img.on('load', function() {
                lazy_masonry();
        });
    } else {
        lazy_masonry();
    }
    
    function lazy_masonry(){
        $('.posts').addClass('loaded');
        $('#masonry').masonry({
            itemSelector: '.post',
            columnWidth: '.grid-sizer'
        });
    }
    
    function lazy_slider(){
        $('.slider').addClass('loaded');
        $('#slides').slidesjs({
            width: 1000,
            height: 400,
            effect: {
                slide: {
                    speed: 1000
                }
            },
            play: {
                active: false,
                  // [boolean] Generate the play and stop buttons.
                  // You cannot use your own buttons. Sorry.
                effect: 'slide',
                  // [string] Can be either "slide" or "fade".
                interval: 5000,
                  // [number] Time spent on each slide in milliseconds.
                auto: false,
                  // [boolean] Start playing the slideshow on load.
                swap: false,
                  // [boolean] show/hide stop and play buttons
                pauseOnHover: true,
                  // [boolean] pause a playing slideshow on hover
                restartDelay: 3000
                  // [number] restart delay on inactive slideshow
            }
        });
    }
    lazy_slider();
        
    $(function() {
        
        //timeago
        $('.timeago').timeago();
        
        //paginar
        $('.posts-pagination a').click(function (event) {
            event.preventDefault();
            var pagina = location.href.match(/pagina\/([0-9]+)/);
            if (!pagina || pagina[1] != $(this).attr('data-pagina')) location.href = BASE_URL+'pagina/'+$(this).attr('data-pagina')
        })
        
        //publicidad
        reloadPublicidad();
        //setInterval(reloadPublicidad, 1000*60*2);
    });
</script>
</body>
</html>
